/*******************************************************************/
/* @ All Rights Reserved Copyright (C) 2014 broada,Co.,Ltd.        */
/*                                                                 */
/*  NAME      = t_main.c                                     */
/*  NOTE      =                                                    */
/*  DATE      = 2014/12/15 by geyh                                 */
/*******************************************************************/

#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#include <CUnit/Basic.h>
#include <CUnit/CUnit.h>
#include <protobuf-c/protobuf-c.h>

#include "../../comm/frcmd_parse_detail.h"
#include "../../comm/client.pb-c.h"
#include "../../comm/frcmd_parse.h"
#include "../../comm/apm.pb-c.h"
#include "../../comm/frcmd_client.h"
#include "../../comm/frcomm.h"
#include "../../comm/frmem.h"
#include "../../comm/frsutl.h"
#include "../../comm/apmtest_cunit.h"
#include "../../comm/cmd.tab.h"

static int __suite_init(void)
{

	return 0;
}

static int __suite_cleanup(void)
{

	return 0;
}

void case1(void)
{
    int i_argc = 7;
    char **pp_cmd;

    pp_cmd = malloc(sizeof(char*)*i_argc);

    pp_cmd[0] = strdup("./client");
    pp_cmd[1] = strdup("-h");
    pp_cmd[2] = strdup("127.0.0.1");
    pp_cmd[3] = strdup("-p");
    pp_cmd[4] = strdup("65535");
    pp_cmd[5] = strdup("-c");
    pp_cmd[6] = strdup("setup filter add 02:ea:b3:a6:79 tcp;");

    int i_ret = 0;

    i_ret = main_tmp(i_argc,pp_cmd);

    CU_ASSERT_EQUAL(i_ret,FR_FAIL);
    free(pp_cmd[0]);
    free(pp_cmd[1]);
    free(pp_cmd[2]);
    free(pp_cmd[3]);
    free(pp_cmd[4]);
    free(pp_cmd[5]);
    free(pp_cmd[6]);
    free(pp_cmd);

    return;

}

int add_suite()
{
	CU_pSuite pSuite = NULL;

	pSuite = CU_add_suite("t_main 测试", __suite_init, __suite_cleanup);

	if (NULL == pSuite)
	{
		return 1;
	}


    //增加测试用例
   	CU_add_test(pSuite, "case1", case1);

    return 0;

}

int main(int argc, char **argv)
{
    frmem_init();
    run_cunit(add_suite);
    frshow_leak();
    frmem_destroy();

    return 0;
}